package com.gpay.erp.services.purchase.impl;

import com.gpay.erp.core.dao.BaseDao;
import com.gpay.erp.core.dao.page.PagerModel;
import com.gpay.erp.services.purchase.ContractService;
import com.gpay.erp.services.purchase.ContractSubService;
import com.gpay.erp.services.purchase.bean.Contract;
import com.gpay.erp.services.purchase.bean.ContractSub;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/8/24 0024.
 */
@Service
public class ContractSubServiceImpl implements ContractSubService {
	@Resource
	private BaseDao dao;
	@Autowired
	private ContractService contractService;

	public int insert(ContractSub contractSub) {
		return dao.insert("contractSub.insert", contractSub);
	}

	public int delete(ContractSub contractSub) {
		return dao.delete("contractSub.deleteById");
	}

	public int deletes(String[] ids) {
		return 0;
	}

	public int update(ContractSub contractSub) {
		return dao.update("contractSub.update", contractSub);
	}

	public ContractSub selectOne(ContractSub contractSub) {
		return null;
	}

	public ContractSub selectById(String id) {
		return (ContractSub) dao.selectOne("contractSub.selectById",id);
	}

	public PagerModel selectPageList(ContractSub contractSub) {
		return dao.selectPageList("contractSub.selectPageList",
				"contractSub.selectPageCount", contractSub);
	}

	public List<ContractSub> selectList(ContractSub contractSub) {
		return null;
	}

	public int getCount(ContractSub contractSub) {
		return dao.getCount("contractSub.selectPageCount", contractSub);
	}

	@Override
	public int updateContractSubById(ContractSub contractSub) {
		return dao.update("contractSub.updateById", contractSub);
	}

	@Override
	public int updateContractSubByFId(ContractSub contractSub) {
		return dao.update("contractSub.updateByFId",contractSub);
	}

	@Override
	public List<ContractSub> selectListByfid(String fid) {
		return dao.selectList("contractSub.selectByFid", fid);
	}

	@Override
	public List<ContractSub> selectByFidAndStatus(ContractSub contractSub) {
		return dao.selectList("contractSub.selectByFidAndStatus", contractSub);
	}

	@Override
	public String getContractSubCode(String contractCode) {
		StringBuffer stringBufferCode = new StringBuffer(
				contractCode);
		stringBufferCode.append("00");

		return stringBufferCode.toString();
	}

	@Override
	public HashMap selectTotalByOne(ContractSub contractSub) {
		return (HashMap)dao.selectOne("contractSub.selectTotalByOne",contractSub);
	}

}
